<script setup>
	import {
		ref,
		reactive,
		watchEffect,
		provide,
		inject,
		onMounted,
		computed,
		getCurrentInstance,
	} from 'vue'

	//两种写法，全部引入取别名和按需引入
	// import * as exampleApi from '../apis/exampleApi'
	import { getExampleData } from '../../apis/exampleApi'
	import request from '../../utils/request'
	import storage from '../../utils/storage'
	import { useRouter } from 'vue-router'

	const router = useRouter()

	// 基本量区
	const data = ref()

	const { proxy } = getCurrentInstance()
	onMounted(() => {
		getExampleData()
			.then((res) => {
				data.value = res.result
				console.log(res.result)
			})
			.catch((err) => {
				console.log(err)
			})
		// 另一种写法 exampleApi.getExampleData()then((req)=>{})
		// exampleApi
		// 	.getExampleData()
		// 	.then((data) => {
		// 		data = data.result
		// 		console.log(data.result)
		// 	})
		// 	.catch((err) => {
		// 		console.log(err)
		// 	})
	})
</script>

<template>
	{{ data }}
	当前路由有：
	<div v-for="r in router.options.routes">
		{{ r }}
	</div>
</template>
<style scoped lang="less"></style>
